import request from '@/utils/request'
import router from '@/router/index'
// 这里写一个常量用来映射不同业务模块和审批接口路径的关系,通过动态获取路由路径
// console.log("route", router.currentRoute.fullPath)
const auditListOptions = {
  '/plant-check/component/add-plan/detail': '/check/api/check/plan/audit/query/list/', // 点检
  '/device-preserve/component/addPlan/detail': '/preserve/api/preservePlan/query/list/audit/', // 保养
  '/device-patrol/component/add-plan/detail': '/patrol/api/patrol/plan/audit/query/list/', // 巡检
  '/device-dataIndentify/component/add-plan/detail': '/verification/verifyPlan/query/list/audit/', // 检定
  '/device-basic/component/detail/index': '/device/api/deviceAsset/query/list/audit/', // 设备
  '/device-repair/repairItems/component/detail/index': '/repair/api/repair/audit/query/list/', // 维修
  '/device-repair/maintenance/component/detail/index': '/repair/api/maintenance/audit/query/list/' // 维护
}
const aduitUrlOptions = {
  '/plant-check/component/add-plan/detail': '/check/api/check/plan/audit', // 点检
  '/device-preserve/component/addPlan/detail': '/preserve/api/preservePlan/audit', // 保养
  '/device-patrol/component/add-plan/detail': '/patrol/api/patrol/plan/audit', // 巡检
  '/device-dataIndentify/component/add-plan/detail': '/verification/api/verifyPlan/audit', // 检定
  '/device-basic/component/detail/index': '/device/api/deviceAsset/audit', // 设备
  '/device-repair/repairItems/component/detail/index': '/repair/api/repair/audit', // 维修
  '/device-repair/maintenance/component/detail/index': '/repair/api/maintenance/audit' // 维护
}
// 查询审批列表
export function fetchList(id) {
  console.log('route', auditListOptions[router.currentRoute.fullPath])
  console.log('route11', id)
  return request({
    url: auditListOptions[router.currentRoute.fullPath] + localStorage.getItem(router.currentRoute.fullPath),
    method: 'get'
    // params: query
  })
}

// 提交审批
export function submitApprove(query) {
  return request({
    url: aduitUrlOptions[router.currentRoute.fullPath],
    method: 'PUT',
    data: query
  })
}
